package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.hosp.bean.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.hosp.utils.HttpRequestHelper;
import com.atguigu.yygh.model.hosp.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/*==========================================
      时 间:   2022-04-19
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@RestController
@RequestMapping("/api/hosp")
public class ApiScheduleController {


    @Autowired
    private ScheduleService scheduleService;



    @PostMapping("/schedule/list")
    public Result shedulePage(HttpServletRequest httpServletRequest){
        Map<String, Object> stringObjectMap = HttpRequestHelper.switchMap(httpServletRequest.getParameterMap());
        Page<Schedule> page=scheduleService.shedulePage(stringObjectMap);

        return Result.ok(page);
    }
    @RequestMapping("/saveSchedule")
    public Result save(HttpServletRequest httpServletRequest){
        Map<String, Object> stringObjectMap = HttpRequestHelper.switchMap(httpServletRequest.getParameterMap());
        //todo:sign校验
        scheduleService.save(stringObjectMap);
        return Result.ok();
    }
}
